<?php
// vim:set expandtab tabstop=3 shiftwidth=3 softtabstop=3 foldclose=all foldmethod=marker:
/**
 * 项目：   5anet
 * 文件：   class/article/ShowIndex.class.php
 *
 * 显示软件的详细情况
 *
 * PHP Version 5
 *
 * @package:   class.article
 * @author:    Mike.G Chinese Name: 黄叶 <hylinux@gmail.com>
 * @license:   http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1 
 * @copyright: www.5anet.com
 * @version:   $Id: $
 * @date:      $Date: $
 */

include_once CLASS_PATH.'main/BaseAction.class.php';

//包含必要的软件工具类
include_once CLASS_PATH.'soft/SoftUtil.class.php';


//定义处理的类

class ShowSoft extends BaseAction {

   /**
    * 数据库的连接
    */
   private $db;


   /**
    * 构造函数
    * @param:  NULL
    * @return: NULL
    * @access: public
    */
   public function __construct() {
      $this->db = $this->getDB();
   }


   /**
    * 显示软件的详细情况
    * @param:  NULL
    * @return: NULL
    * @access: public
    */
   public function run() {
      
      $id = $this->getParameterFromGET('id');

      if ( !$id ) {
         $this->AlertAndBack('没有指定要查看的软件');
         return;
      }

      if ( ! SoftUtil::isExists($this->db, $id) ) {
         $this->AlertAndBack('软件不存在');
         return;
      }


      $smarty = $this->getSmarty();

      //取得软件的详细信息
      $soft_info = SoftUtil::getSoftInfo($this->db, $id);

      //assign软件名称和软件的id
      $smarty->assign('soft_name', $soft_info['name']);
      $smarty->assign('soft_id', $soft_info['id']);
      $smarty->assign('soft_version', $soft_info['version']);
      $smarty->assign('soft_type', $soft_info['type']);
      $smarty->assign('soft_website', $soft_info['website']);
      $smarty->assign('soft_downloads', $soft_info['downloads']);
      $smarty->assign('soft_comment', $soft_info['comment']);


      //设置SEO
      $smarty->assign('clone_title', $soft_info['name'].' version:'.$soft_info['version'].' -- 软件下载 -- 5anet.com' );
      $smarty->assign('header_meta_content', $soft_info['name'].' version:'.
         $soft_info['version'].' -- 软件下载 -- 5anet.com' );


      //取得所有的软件分类的格式
      $category = SoftUtil::getCategory($this->db);
      $smarty->assign('all_catagory', $category);


      //取得软件的图像
      $image = SoftUtil::getImage($this->db, $id);

      $smarty->assign('image', $image);


      //取得软件的评论
      $soft_comment = SoftUtil::getSoftComment($this->db, $id);
      $smarty->assign('comment', $soft_comment);






      $smarty->display('showsoft.tmpl');



   }
}


?>
